<template>
  <div class="messagePanel">
    <div class="messageHeader">您有  {{data.length}} 条消息</div>
    <div class="messageContent">
      <div v-for="item in data" :key="item.key" class="messageItem">
        <div class="messageAvatar">
          <img class="avatar" :src="require('@/assets/user.png')" alt="" />
        </div>
        <span class="sender">{{item.sender}}</span>
        <span class="time">
          <li class="fa fa-clock-o"></li> {{item.time}}
        </span>
        <div class="messageContent">
          {{item.content}}
        </div>
      </div>
    </div>
    <div class="messageFooter">查看所有消息</div>
  </div>
</template>

<script>
export default {
  name: "MessagePanel",
  props: {
    data: {
      type: Array,
      default: () => [
        {
          key: "1",
          avatar:'@/assets/user.png',
          content:'你修改了用户密码',
          sender:'诸葛亮',
          time:'5分钟前'
        },
        {
          key: "2",
          avatar:'@/assets/user.png',
          content:'你修改了用户头像',
          sender:'武则天',
          time:'2小时前'
        },
        {
          key: "3",
          avatar:'@/assets/user.png',
          content:'今日25名新成员加入',
          sender:'王语嫣',
          time:'昨天'
        },
        {
          key: "4",
          avatar:'@/assets/user.png',
          content:'您发表了一篇新随笔',
          sender:'苍井空',
          time:'昨天'
        },
        {
          key: "5",
          avatar:'@/assets/user.png',
          content:'您发表了一篇新随笔',
          sender:'上官婉儿',
          time:'前天'
        }
      ]
    }
  },
  data(){
    return{

    }
  },
  methods: {
    handleClick: function (){
      // 按钮操作处理函数
      this.$emit('click',{})
    }
  },
  mounted(){

  }
}
</script>

<style scoped>
.messagePanel {
  font-size: 15px;
  width: 300px;
  margin: -12px;
}
.messageHeader {
  padding-left: 10px;
  font-size: 14px;
  padding-top: 6px;
  padding-bottom: 6px;
}
.messageContent {
  font-size: 15px;
}
.messageItem {
  border-color: rgba(180, 190, 190, 0.8);
  border-top-width: 1px;
  border-top-style: solid;
  padding-top: 10px;
  padding-bottom: 10px;
}
.messageItem:hover {
  cursor: pointer;
  background: #b1a6a61e;
}
.messageAvatar {
  padding-left: 10px;
}
.avatar {
  margin-right: 10px;
}
.sender {
  font-size: 16px;
  font-weight:bold;
}
.time {
  font-size: 12px;
  float: right;
  padding-right: 10px;
}
.messageFooter {
  font-size: 14px;
  text-align: center;
  padding-top: 10px;
  padding-bottom: 10px;
  border-color: rgba(180, 190, 190, 0.8);
  border-top-width: 1px;
  border-top-style: solid;
}
.messageFooter:hover {
  cursor: pointer;
  background: #b1a6a61e;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 90px;
  float: left;
}
</style>
